#include <cstdio> 
using namespace std;
template <typename T>
inline void read(T& x)
{
    int c=getchar(), f=1; x=0;
    while(c<'0'||'9'<c) {if(c=='-') f=-1; c=getchar();}
    while('0'<=c&&c<='9') 
        x=(x<<3)+(x<<1)+c-'0', c=getchar();
    x*=f;
}

inline void write(long long x)
{
    if(x>=10) write(x/10);
    putchar(x%10+'0');
}
#define DEBUG
using ll=long long;
#define f(x) (x*x+b*x+c)
int b, c, l, r;
ll ans;
void init()
{
    read(b), read(c), read(l), read(r);
    if(l%2) l++;
    if(r%2) r--;
}


void solve()
{
    init();
    for(int i=l; i<=r; i+=2)
        ans+=1ll*f(i);
    write(ans<<1); puts("");
}

signed main()
{
    #ifdef DEBUG
        freopen("../in.txt", "r", stdin);
        freopen("../out.txt", "w", stdout);
    #endif

    int T=1; //scanf("%d", &T);
    while(T--) 
    {
        solve();
    }
    return 0;
}